package com.quick.develop.flowable.controller.task;

import com.quick.develop.framework.common.page.R;
import com.quick.develop.flowable.service.task.IBpmActivityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author junyuan.liu
 * @description: TODO
 * @date 2022/5/2 14:30
 */
@Api(tags = "管理后台 - 流程活动实例")
@RestController
@RequestMapping("/activity")
@Validated
public class BpmActivityController {
    @Resource
    private IBpmActivityService activityService;

    @GetMapping("/history-list")
    @ApiOperation(value = "历史节点信息")
    @ApiImplicitParam(name = "processInstanceId", value = "流程实例的编号", required = true, dataTypeClass = String.class)
    public R<?> getHisActivityList(@RequestParam("processInstanceId") String processInstanceId){
        return R.ok(activityService.getHisActivityListByProcessInstanceId(processInstanceId));
    }

    @GetMapping("/isCallActivityFinished")
    @ApiOperation(value = "当前流程处于调用活动，且是否全部完成")
    public R<Boolean> isCallActivityFinished(@RequestParam("processInstanceId") String processInstanceId){
        return R.ok(activityService.isCallActivityFinished(processInstanceId));
    }
    
    @GetMapping("/get-viewer-activity")
    @ApiOperation(value = "获取流程执行过程")
    public R<?> getBpmViewerActivity(@RequestParam("processInstanceId") String processInstanceId){
        return R.ok(activityService.getBpmViewer(processInstanceId));
    }
    
    @GetMapping("/get-run-activities/{processInstanceId}")
    @ApiOperation(value = "获取流程正在运行的活动列表")
    public R<?> getRunActivityList(@PathVariable("processInstanceId") String id) {
        return R.ok(activityService.getRunActivityList(id));
    }
    
    

}
